<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\widgets\ListView;
use yii\grid\GridView;
use backend\helpers\ActionButton;
use backend\helpers\FileViewHelper;
use backend\helpers\DateTimeHelper;
use backend\models\Project;
use kartik\export\ExportMenu;

/* @var $this yii\web\View */
/* @var $model backend\models\Project */


$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Проекты', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;

$this->params['id'] = $model->id;

?>
<div class="container project-view">

    <h1 class="main-title"><?= Html::encode($this->title) ?></h1>

    <div class="row">
        <div class="col-sm-11"><?= $this->render('/project/_menu') ?></div>
        <div class="col-sm-1"><?= ActionButton::delete($model->id, 'Вы точно хотите удалить информацию о проекте?', 'deleteProject') ?></div>
    </div>
    <br>
    <br>
    <div class="row">
        <div class="col-sm-2"><?= ActionButton::createWithURI('Добавить пожертвование', ['project-donation/create', 'project_id' => $model->id], 'updateProject') ?></div>
    </div>

    <br>
    <br>

    <table class="table table-striped detail-view">
        <tbody>
            <tr>
                <th>Общая сумма пожертвований</th>
                <td><?= Yii::$app->formatter->asCurrency($model->getDonations()->sum('price')) ?></td>
            </tr>
        </tbody>
    </table>

    <br>
    <br>

    <?= ListView::widget([
        'dataProvider' => $dataProvider,
        'itemView' => function ($model, $key, $index, $widget) {
            if(!$model->is_direct_donation)
            {
                return $this->render('_donation-contract', ['model' => $model]);
            }
            else
            {
                return $this->render('_donation-direct', ['model' => $model]);
            }
        },
        'layout' => "{items}",
    ]) ?>


</div>

